'''
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with self work for additional information
 * regarding copyright ownership.  The ASF licenses self file
 * to you under the Apache License, Version 2.0 (the
 * "License") you may not use self file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http:#www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
'''


#import org.apache.jena.rdf.model.Resource;

'''
 * A Mode object controls whether persistent objects can be created or reused
 * by an assembler. Their methods are expected to be called when an
 * assembler is about to create a object (because no object with the given
 * name exists) or reuse an existing one (because one does).
 *
 * <p>The default behaviour of the methods is dictated by booleans bound into
 * the mode object. Subclasses of mode may exploit the ability to inspect the
 * name of the object or its other RDF properties.
'''
Mode
    '''
     * Mode that demands a object be created and no existing object
     * should exist.
    '''
    public static final Mode CREATE = Mode(True, False)

    '''
     * Default mode existing objects are reused, objects are not created
    '''
    public static final Mode DEFAULT = Mode(False, True)

    '''
     * Mode that requires that objects should already exist objects cannot
     * be created.
    '''
    public static final Mode REUSE = Mode(False, True)

    '''
     * Mode that permits existing objects to be reused and objects to
     * be created.
    '''
    public static final Mode ANY = Mode(True, True)

    protected final boolean mayCreate
    protected final boolean mayReuse

    public Mode(boolean mayCreate, boolean mayReuse):
        self.mayCreate = mayCreate
        self.mayReuse = mayReuse
    

    '''
     * Answer True if the object <code>root</code> with the given <code>name</code>
     * can be created if it does not already exist.
    '''
    # param Resource root, String name
    # result boolean
    def permitCreateNew(self, root, name):
        return mayCreate
    

    '''
     * Answer True if the existing object <code>root</code> with the given
     * <code>name</code> can be reused.
    '''
    # param Resource root, String name
    # result boolean
    def permitUseExisting(self, root, name):
        return mayReuse
    

